1 using System;
2 using
UnityEngine;
3
4 namespace
UnityStandardAssets.Water
5 {
6     
[RequireComponent(typeof(WaterBase))]
7     
[ExecuteInEditMode]
8     
public class SpecularLighting : MonoBehaviour
9     {
10         
public Transform specularLight;
11         
private WaterBase m_WaterBase;
12
13
14         
public void Start()
15         {
16             m_WaterBase = (WaterBase)gameObject.GetComponent(
typeof(WaterBase));
17         }
18
19
20         
public void Update()
21         {
22             
if (!m_WaterBase)
23             {
24                 m_WaterBase = (WaterBase)gameObject.GetComponent(
typeof(WaterBase));
25             }
26
27             
if (specularLight && m_WaterBase.sharedMaterial)
28             {
29                 m_WaterBase.sharedMaterial.SetVector(
"_WorldLightDir", specularLight.transform.forward);
30             }
31         }
32     }
33 }


Gõ tìm kiếm nhanh...